package net.cyue.nest.nestjava.platform.vertx;

import io.vertx.core.http.HttpServerResponse;
import net.cyue.nest.nestjava.common.enums.HTTPStatus;
import net.cyue.nest.nestjava.common.util.JSONUtil;
import net.cyue.nest.nestjava.core.adapter.AbstractHTTPResponse;

@Deprecated
public class VerticleHTTPResponse
 extends AbstractHTTPResponse<HttpServerResponse> {
  public VerticleHTTPResponse(HttpServerResponse response) {
    this.response = response;
  }

  @Override
  public void status(HTTPStatus status) {
    this.response.setStatusCode(status.code());
  }

  @Override
  public void putHeader(String name, String value) {
    this.response.putHeader(name, value);
  }

  @Override
  public void removeHeader(String name) {
    this.response.putHeader(name, "");
  }

  @Override
  public void redirect(HTTPStatus status, String url) {
    this.status(status);
    System.out.println("redirect 暂未开发");
  }

  @Override
  public void redirect(String url) {
    System.out.println("redirect 暂未开发");
  }

  @Override
  public void end(String s) {
    this.response.end(s);
  }

  @Override
  public void send(String body) {
    this.response.send(body);
  }

  @Override
  public void send(Object body) {
    String jsonString = JSONUtil.toJSONString(body);
    this.response.putHeader("Content-Type", "application/json;charset=utf-8");
    this.response.send(jsonString);
  }

  @Override
  public void write(String s) {
    this.response.write(s);
  }
}
